#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int LevenDistance(string& s1, string& s2)
{
    int len1 = s1.size(), len2 = s2.size();
    if(len1 == 0 || len2 == 0)
        return max(len1, len2);
    // 动规数组
    vector<vector<int>> vv(len1+1, vector<int>(len2+1, 0));
    // 初始化首行首列
    for(int i = 0; i <= len1; ++i)
        vv[i][0] = i;   // 第0列
    for(int j = 0; j <= len2; ++j)
        vv[0][j] = j;  // 第0行
    
    for(int i = 1; i <= len1; ++i){
        for(int j = 1; j <= len2; ++j){
            if(s1[i-1] == s2[j-1]){
                vv[i][j] = min(vv[i-1][j]+1, vv[i][j-1]+1);  // 插入和删除
                vv[i][j] = min(vv[i][j], vv[i-1][j-1]);   // 替换
            }
            else{
                vv[i][j] = min(vv[i-1][j], vv[i][j-1]) + 1;   // 插入和删除
                vv[i][j] = min(vv[i][j], vv[i-1][j-1] + 1);   // 替换
            }
        }
    }
    return vv[len1][len2];
}

int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    if(s1.size()+s2.size() == 0)
        return 0;
    cout << LevenDistance(s1, s2);
    return 0;
}